home *** CD-ROM | disk | FTP | other *** search
/ HyperLib 1997 Winter - Disc 1 / HYPERLIB-1997-Winter-CD1.ISO.7z / HYPERLIB-1997-Winter-CD1.ISO / オンラインウェア / PRG / nShell-Pro.sit / nShell-Pro / doc / nShell™ User's Guide.rsrc / TEXT_130.txt < prev    next >
Text File  |  1994-12-27  |  5KB  |  106 lines

  1.  
  2. Getting Started
  3.  
  4. Shell environments differ from Graphical User Interfaces in their tone and their style of interaction.  When Graphical Interfaces model objects on the screen, users interact with them as they would with physical objects.  The user may pick up an object, examine it, and put it away.  In contrast, Shell Interfaces are conversational in nature.  The user types a command to the computer, and the computer responds with a few words of its own.
  5.  
  6. The strength of this conversational metaphor is that it naturally develops into a script of actions.  For example, a user might type a few commands to do a weekly clean-up of her system.  These same commands can be used to construct a clean-up script.
  7.  
  8. Simple Commands
  9.  
  10. The simplest commands are single words.  If you type "date" in the nShell, it will respond with the current date and time:
  11.  
  12.     % date
  13.     Friday, April 22, 1994 9:13:52 AM
  14.     %     
  15.  
  16. A number of commands work this way, as simple requests for information.  As a further example, the "ps" command lists programs that are running:
  17.  
  18.     % ps
  19.      Process Crea Type  Mem Size   Mem Free  Name
  20.      ------- ---- ---- ---------- ---------- ----
  21.         8192 MACS FNDR     175104       6932 Finder
  22.         8193 hhgg INIT     187392      24434 File Sharing Extension
  23.         8194 pbc2 INIT     114688      25708 Printer Share
  24.         8197 ttxt APPL     540672     461856 SimpleText
  25.         8199 NSHA APPL     425984     322042 nShell邃「
  26.  
  27. Command Options
  28.  
  29. Some commands, including "date", have command-line options.  These options are selected using the "-" character.  As an example, the "-d" option means "date only" and prevents the time from being displayed:
  30.  
  31.     % date -d
  32.     Friday, April 22, 1994
  33.  
  34. Another option for the date command is "-s", which means "short date":
  35.  
  36.     % date -s
  37.     4/22/94 9:23:26 AM
  38.  
  39. More than one option may be used at a time.  If we wanted the "short date" with "date only", we could add both options or combine them behind one "-":
  40.  
  41.     % date -d -s
  42.     4/22/94
  43.     % date -sd
  44.     4/22/94
  45.  
  46. Command Parameters
  47.  
  48. In some cases we want to pass more data to a command than with an option.  Command parameters are general text strings which are passed to the command for processing.  The "echo" command provides an example.  Echo takes however many parameters it receives and prints the back out:
  49.  
  50.     % echo hello there
  51.     hello there
  52.  
  53. In this case echo has two parameters, the string "hello" and the string "there".  The nShell normally splits parameters at space characters.  If you want to put more than one word into a parameter, you can use quotes to protect the spaces.  Compare the following:
  54.  
  55.     % echo a     b     c     d
  56.     a b c d
  57.     % echo "a     b     c     d"
  58.     a     b     c     d
  59.  
  60. In the first case four parameters were specified "a", "b", "c" and "d".  In the second case a single parameter was given - the string "a     b     c     d".
  61.  
  62. The ability to protect spaces is important in the Macintosh because the names of folders and files often contain them.
  63.  
  64. Standard Input
  65.  
  66. Commands may expect additional data to be provided after the command line.  An example is the "notify" command.  This command posts an informational dialog.  The text for the dialog may be provided on the command line, or follow it as standard input.  One advantage of using standard input is that more than one line of text can be entered.  To signal the end of standard input, type a ^D (the ctrl and d keys pressed in unison).
  67.  
  68. Using the command line:
  69.  
  70. % notify "This is a test."
  71.  
  72. Using standard input:
  73.  
  74. % notify
  75. This is a test.
  76. And it has two lines.^D
  77.  
  78. The main advantage of standard input is that a command may be told to collect text from someplace other than the keyboard.  Standard input may be collected from a file or from another command.  See the "Input/Output Redirection" section of this manual for more information.
  79.  
  80. Halting Commands
  81.  
  82. Shell commands may be halted using ^C (the ctrl key and the c key held down in unison).  A ^C will halt processing in the frontmost shell window and produce new prompt (%).
  83.  
  84. The command-. key combination will halt processing in all shells, and produce a new prompt in each.
  85.  
  86. The Online Manual
  87.  
  88. It is sometimes difficult to remember what options and parameters a command accepts.  To deal with this problem, Shell environments have a traditional form of on-line help called "man pages" (short for Manual Pages).  This on-line manual is searched by typing "man <command name>", as in:
  89.  
  90.     % man date
  91.  
  92.     [I won't repeat the full man page here, try it yourself!]
  93.  
  94. In some cases a man page has subsections available.  In the case of "date" an "examples" page may be printed.  The subsection is added to the end of the line:
  95.  
  96.     % man date examples
  97.  
  98. While man pages are available for Flow Of Control commands, such keywords (if, then, else, endif, while, until, do, done) must be quoted on the command line:
  99.  
  100.     % man "if"
  101.  
  102. What's Next?
  103.  
  104. The examples given above should be enough to get you started with the nShell.  Once you get the basic techniques in order, you may want to look at the more advanced sections on wildcards, scripting, and input/output redirection.
  105.  
  106. Good Luck.